#include <iostream>

using namespace std;

const int N = 1e5 + 10;

typedef long long LL;

int n, m;
LL a[N], f[N];

int main()
{
	cin >> n >> m;
	for(int i = 1; i <= n; i++) 
	{
		cin >> a[i];
		f[i] = a[i] + f[i - 1];
	}

	int l, r;
	while(m--)
	{
		cin >> l >> r;
		cout << f[r] - f[l - 1] << endl;
	}

	return 0;
}